﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace JsonRpc
{

    public class RequestingEventArgs : EventArgs
    {
        public string RequestText { get; set; }
    }

    public class MethodInvokingEventArgs : EventArgs
    {
        public JsonRpcRequest request { get; set; }
        public bool Cancel { get; set; }
        public string CancelMessage { get; set; }

        public MethodInvokingEventArgs()
        {
            Cancel = false;
        }
    }

    public class MethodInvokedEventArgs : EventArgs
    {
        public JsonRpcResponse Response { get; set; }

    }

    public class RespondingEventArgs : EventArgs
    {
        public string ResponseText { get; set; }
    }

    public partial class JsonRpcService
    {
        public event EventHandler<RequestingEventArgs> Requesting;
        public event EventHandler<MethodInvokingEventArgs> MethodInvoking;
        public event EventHandler<MethodInvokedEventArgs> MethodInvoked;
        public event EventHandler<RespondingEventArgs> Responding;

        protected virtual void OnRequesting(RequestingEventArgs e)
        {
            if (Requesting != null)
                Requesting(this, e);
        }

        protected virtual void OnMethodInvoking(MethodInvokingEventArgs e)
        {
            if (MethodInvoking != null)
                MethodInvoking(this, e);
        }

        protected virtual void OnMethodInvoked(MethodInvokedEventArgs e)
        {
            if (MethodInvoked != null)
                MethodInvoked(this, e);
        }

        protected virtual void OnResponding(RespondingEventArgs e)
        {
            if (Responding != null)
                Responding(this, e);
        }

    }

}